<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
<%--    http://localhost:8080/atcrowdfunding02/test/ssm.html--%>
    <base href="http://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
    <script type="text/javascript" src="jquery/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="layer/layer.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#btn1").click(function () {
                alert("good");
                $.ajax({
                    "url" : "sent/arrayOne.html",
                    "type" : "post",
                    "data" : {
                        "array" : [5, 8, 12]
                    },
                    "dataType" : "text",
                    "success" : function (response) {
                        alert(response);
                    },
                    "error" : function (response) {
                        alert(response);
                    }
                });
            });


            var array = [5, 8, 12];
            var arrayStr = JSON.stringify(array);
            $("#btn2").click(function () {
                $.ajax({
                    "url" : "sent/arrayTwo.html",
                    "type" : "post",
                    "data" : arrayStr,
                    "contentType":"application/json;charset=UTF-8",
                    "dataType" : "text",
                    "success" : function (response) {
                        alert(response);
                    },
                    "error" : function (response) {
                        alert(response);
                    }
                });
            });

            var student = {
                "stuId" : 34,
                "stuName" : "赵效来",
                "address" : {
                    "province" : "河南省",
                    "city" : "开封市",
                    "street" : "龙亭区"
                },
                "subjectList" : [
                    {
                        "subjectName" : "英语",
                        "subjectScore" : "99"
                    },
                    {
                        "subjectName" : "数学",
                        "subjectScore" : "99"
                    }
                ],
                "map" : {
                    "key1" : "value1",
                    "key2" : "value2",
                    "key3" : "value3",
                    "key4" : "value4",
                    "key5" : "value5"
                }
            };
            var sendDataC = JSON.stringify(student);
            $("#btn3").click(function () {
                $.ajax({
                    "url" : "sent/arrayThree.json",
                    "type" : "post",
                    "data" : sendDataC,
                    "contentType":"application/json;charset=UTF-8",
                    "dataType" : "json",
                    "success" : function (response) {
                        console.log(response);
                    },
                    "error" : function (response) {
                        console.log(response);
                    }
                });
            });

            $("#btn4").click(function () {
                layer.msg("layer弹窗");
            });
        });
    </script>
</head>

<h2>Hello World!</h2>
<%--<a href="${pageContext.request.contextPath}/test/ssm.html">测试SSM整合环境</a>--%>
<a href="test/ssm.html">测试SSM整合环境</a>
<br>

<%--<button id="btn1">ajax 请求：方案一</button>
<button id="btn2">ajax 请求：方案二</button>
<button id="btn3">ajax 请求：发送复杂json对象</button>
<button id="btn4">layer：弹框</button>--%>
<jsp:forward page="/admin/to/login/page.html"></jsp:forward>
</body>
</html>
